package cn.ad.param;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 代理商查询
 * Created by Administrator on 2016/9/7.
 */
public class AgencyQuery extends AbstractPagingSortParam {

    private String search;

    public String getSearch() {
        return search;
    }

    public void setSearch(String search) {
        this.search = search;
    }

    /**
     * 默认按id排序
     */
    @Override
    public String getSortby() {
        return StringUtils.isEmpty(super.getSortby()) ? "id" : super.getSortby();
    }

    /**
     * 默认按降序排序
     */
    @Override
    public ORDER getOrder() {
        return super.getOrder() == null ? ORDER.desc : super.getOrder();
    }

    @JsonIgnore
    public Map<String,Object> getSearchMap(){
        Map<String,Object> map=new HashMap<>();
        map.put("search",this.search);
        map.put("offset",this.getOffset());
        map.put("limit",this.getLimit());
        map.put("order",this.getOrder());
        map.put("sortby",this.getSortby());
        return map;
    }
}
